import i18nTranslate_zh from './zh'

export default function getI18nTranslate(): (template: string, replacements: { [index: string]: string }) => any {
  const i18nTranslate: any = i18nTranslate_zh
  return function customTranslate(template, replacements) {
    replacements = replacements || {}

    // Translate
    template = i18nTranslate[template] || template

    // Replace
    return template.replace(/{([^}]+)}/g, function (_: string, key: string) {
      return replacements[key] || '{' + key + '}'
    })
  }
}
